package com.test.mooan.labama.activity_fragment_boom.base_boom;

import android.content.Context;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.test.mooan.labama.utils_boom.helper_boom.UserInfoHelper_boom;


public abstract class BaseFragment_boom extends Fragment {

    public String pageTag;

    private Runnable onAttachRunnable;

    @Override
    public void onResume() {
        super.onResume();
        if (TextUtils.isEmpty(pageTag)) pageTag = getClass().getSimpleName();
        UserInfoHelper_boom.gInstance().addEventPoint((pageTag + "_START").toUpperCase());
    }

    @Override
    public void onPause() {
        super.onPause();
        if (TextUtils.isEmpty(pageTag)) pageTag = getClass().getSimpleName();
        UserInfoHelper_boom.gInstance().addEventPoint((pageTag + "_END").toUpperCase());
    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        if (onAttachRunnable!=null){
            onAttachRunnable.run();
            onAttachRunnable = null;
        }
    }

    public void runOnAttach(Runnable runnable){
        if (isAdded()) runnable.run();
        else onAttachRunnable = runnable;
    }

}
